import BH3MysApi from "./mysApi.js"
import base from "./base.js"
import mysCfg from "./mysCfg.js"
export default class newAbyss extends base {
  constructor(e) {
    super(e)
  }

  async getData(e) {
    let { uid, ck, game_biz, region } = await mysCfg.othergame(e)
    let mysApi = new BH3MysApi(uid, ck, { game: "bh3" }, region, game_biz)
    let device_fp = await mysApi.getData("getFp")
    let headers = { "x-rpc-device_fp": device_fp?.data?.device_fp }
    let data = await mysApi.getBH3ApiData("oldAbyssReport", { headers })
    let res = await mysApi.getBH3ApiData("newAbyssReport", { headers })
    let reports = res.data.reports.map(report => {
      const date = new Date(report.updated_time_second * 1000)
      const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`
      return {
        ...report,
        updated_time: formattedDate,
      }
    })
    return { ...this.screenData, reports, data }
  }
}
